package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.logic.activity.hotpotjump.HotpotJumpConfig;
import com.yanqu.road.server.manger.activity.jumppot.HotpotJumpMgr;

import java.util.ArrayList;
import java.util.List;

public class HotpotJumpRecycleStrategy extends AbstractItemRecycleStrategy {
    @Override
    public void markNeedRecycleItem() {
        HotpotJumpConfig config = HotpotJumpMgr.getConfig();
        if (config != null) {
            long recycleTime = config.getActivityInfo().getEndShowTime() * 1000L + 300 * 1000;//展示期结束回收
            List<Integer> powerGoodsIds = new ArrayList<>(config.getEnergyCost().getGoods().keySet());
            for (Integer powerGoodsId : powerGoodsIds) {
                ActivityItemRecycleMgr.addRecycleItemData(powerGoodsId, config.getActivityInfo().getType(), 2, recycleTime, new ArrayList<>());
            }
            int refreshItemId = config.getRefreshItemId();
            ActivityItemRecycleMgr.addRecycleItemData(refreshItemId, config.getActivityInfo().getType(), 2, recycleTime, new ArrayList<>());

            int tokenDollId = config.getTokenDollId();
            ActivityItemRecycleMgr.addRecycleItemData(tokenDollId, config.getActivityInfo().getType(), 2, recycleTime, new ArrayList<>());
        }

    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.HotpotJump.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        int recycleType = data.getRecycleType();
        if (recycleType == 2) {
            UserBagItem userBagItem = getUserBagItem(userId, data.getItemId());
            if (userBagItem != null && userBagItem.getNum() > 0) {
                removeItem(userBagItem);
            }
        }
    }
}
